package com.lzkj.baotouhousingfund.model.db;

import android.content.Context;

import io.realm.Realm;
import io.realm.RealmConfiguration;


/**
 * Created by codeest on 16/8/16.
 */

public class RealmHelper {

    private static final String DB_NAME = "BaoTouHousingFund.realm";

    private Realm mRealm;

    public RealmHelper(Context mContext) {
        Realm.init(mContext);
        mRealm = Realm.getInstance(new RealmConfiguration.Builder()
                .deleteRealmIfMigrationNeeded()
                .name(DB_NAME)
                .build());
    }

    public boolean isCloseRealm() {
        return mRealm.isClosed();
    }

    public void closeRealm() {
        mRealm.close();
    }
//
//    /**
//     * 保存欢迎页数据
//     *
//     * @param list
//     */
//    public void insertSplash(List<Splash> list) {
//        mRealm.beginTransaction();
//        mRealm.copyToRealmOrUpdate(list);
//        mRealm.commitTransaction();
//    }
//
//    /**
//     * 查询欢迎页数据
//     *
//     * @return
//     */
//    public List<Splash> querySplashes() {
//        RealmResults<Splash> realmResults = mRealm.where(Splash.class).findAll();
//        List<Splash> list = new ArrayList<>();
//        list.addAll(realmResults);
//        return list;
//    }

}
